package cn.edu.scau.sec.caixiaoqing.composite.transparentcomposite;

import java.util.ArrayList;

public class TransparentTestSuite implements TransparentTestCase{

    private ArrayList<TransparentTestCase> transparentTestCaseList;

    public TransparentTestSuite(){
        transparentTestCaseList = new ArrayList<>();
    }

    @Override
    public boolean test() {
        for (TransparentTestCase  testCase:
                transparentTestCaseList) {
            boolean success = testCase.test();
            if (testCase instanceof AtomTransparentTestCase){
                if (success) System.out.println("测试通过。");
                else System.out.println("测试没有通过，请检查测试数据和被测试的方法，查找测试没有通过的原因。");
            }

        }
        return true;
    }

    @Override
    public void add(TransparentTestCase transparentTestCase) {
        transparentTestCaseList.add(transparentTestCase);
    }

    @Override
    public void remove(TransparentTestCase transparentTestCase) {
        transparentTestCaseList.remove(transparentTestCase);
    }

    @Override
    public TransparentTestCase getTestCase(int index) {
        return transparentTestCaseList.get(index);
    }
}
